<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Sale extends FrontEndController {
    public function __construct() {
        parent::__construct();
        $this->load->model('repo/product_sale_model', 'product_sale_model');
        $this->load->library('mypaging');
        $this->mypaging->setCount($this->product_sale_model->countSale());
        $this->mypaging->setLimit(SALE_LIMIT);
        $this->mypaging->setMainURL(sale_url());
        $this->mypaging->setSuffix($this->config->item('url_suffix'));
    }

    public function index($pageIndex=1) {
        $offset    = ($pageIndex-1) * PRODUCT_LIMIT;
        $pagingBar = $this->mypaging->getBar($pageIndex);
        $aSale     = $this->product_sale_model->getSale($offset);
        $aReturn   = array('pageTitle'=>'Khuyến mãi', 'aSale' => $aSale, 'pagingBar'=>$pagingBar);
        $this->renderView('pages/sale', $aReturn);
    }
}
?>